/**
 * localStorage 封装
 */

export default {
  set(key: string, value: unknown) {
    localStorage.setItem(key, JSON.stringify(value));
  },
  get(key : string) {
    const value =  localStorage.getItem(key);
    if(!value) {
      return '';
    }
    try {
      return JSON.parse(value);
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    } catch (error) {
      return value;
    }
  },
  remove(key : string) {
    localStorage.removeItem(key);
  },
  clear() {
    localStorage.clear();
  },
};
